/*
 * Author: Duncan Grant
 * Title: RADiFy
 * Description: Bookmarklet to explore/edit RDFa
*/
(function($) {
    
    // event handlers are performed when the DOM is ready
    $(document).ready(function() {
        $('#radifyClose').click(function() {
            // remove bookmarklet from DOM
            $('#radifyContainer').remove();
        });
        $('#radifyMinmax').click(function() {
            var img = $(this).attr('src');
            if(img == 'img/min.png') {
                // minimise bookmarklet
                $('#radifyContent').hide();
                $(this).attr('src', 'img/max.png');
            } else {
                // maximise bookmarklet
                $('#radifyContent').show();
                $(this).attr('src', 'img/min.png');
            }
        });
        $('#radifyContainer a').click(function(e) {
            e.preventDefault();
        });
    });
    
    Function.prototype.method = function (name, func) {
        if(!this.prototype[name]) {
            this.prototype[name] = func;
            return this;
        } else {
            return undefined;
        }
    };
    
    String.method('trim', function() {
        return this.replace(/^\s+|\s+$/g, '');
    });
    
    Function.method('curry', function() {
        var slice = Array.prototype.slice,
            args = slice.apply(arguments),
            that = this;
        return function () {
            return that.apply(null, args.concat(slice.apply(arguments)));
        };
    });
    
    var Radify = function () {
        // Begin transmission.
    };
    
    Radify.prototype.parseOntologies = function () {
        var ontologies = [];
        return ontologies;
    }
    
    // subject (URI), predicate (URI), object
    /*
    Within each array index, hold an object for the triple:
    {
        subject: 'foo',
        predicate: 'bar',
        object: 'yoo'
    }
    */
    Radify.prototype.parseTriples = function () {
        var triples = [];
        return triples;
    }
    
})(jQuery);